<?php

class RaiseConvert extends RaiseStaticClass{
    
    const TO_ARRAY = 'Array';
    const TO_BOOLEAN = 'Boolean';
    const TO_COLLECTION = 'Collection';
    const TO_DATETIME = 'DateTime';
    const TO_DOUBLE = 'Double';
    const TO_INTEGER = 'Integer';
    const TO_OBJECT = 'Object';
    const TO_POINT = 'Point';
    const TO_RECTANGLE = 'Rectangle';
    const TO_STRING = 'String';
    
    public static function to($type, $subject){
        $class = 'Raise' . $type . 'Converter';
        Raise::load('core.helper.convert.datatype.' . $class);
        $converter = new $class();
        if($converter instanceof RaiseAbstractConverter){
            return $converter->convert($subject);
        }
        throw new RaiseRuntimeException('RaiseConvert::to() Unable to find suitable converter class for "' . $type . '".');
    }
    
}
